<template>
  <div>
    <el-table :data="tableData" stripe border :max-height="maxTableHeight" style="width: 100%">
      <el-table-column prop="username" label="资产编号" sortable resizable show-overflow-tooltip align="center" />
      <el-table-column prop="name" label="设备名称" resizable show-overflow-tooltip align="center" />
      <el-table-column prop="name" label="安装日期" resizable show-overflow-tooltip align="center" />
      <el-table-column prop="phone" label="安装位置" resizable show-overflow-tooltip align="center" />
      <el-table-column prop="room" label="设备状态" resizable show-overflow-tooltip align="center" />
      <el-table-column prop="room" label="更新时间" resizable show-overflow-tooltip align="center" />
      <el-table-column fixed="right" label="操作" width="300" resizable show-overflow-tooltip align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="warning" icon="el-icon-edit" plain @click="handleEdit(scope.$index, scope.row)">
            编辑
          </el-button>
          <el-button size="mini" type="danger" icon="el-icon-delete" plain @click="handleDelete(scope.$index, scope.row)">
            删除
          </el-button>
          <el-button size="mini" type="primary" icon="el-icon-document" plain @click="handleDetails(scope.$index, scope.row)">
            详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <edit ref="edit" />
  </div>

</template>

<script>
import Edit from './Edit.vue'
export default {
  components: {
    Edit
  },
  props: {
    maxTableHeight: {
      type: String | Number
    },
    tableData: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {

    }
  },
  methods: {
    handleEdit() {
      this.$refs.edit.togglePopup(true)
    },
    // 详情
    handleDetails(index, row) {
      this.$router.push({
        name: 'PersonnelDetails',
        params: {
          id: row.id
        }
      })
    }
  }

}
</script>
